/**
 * Created by 陈奇 on 14-11-15.
 */
var express = require('express');
var router = express.Router();
var db = require('./conn');//先引入数据库链接

router.get('/', function(req, res) {
    var userName2 = req.param('username');
    var userPwd2 = req.param('userpass');

    db.pool.getConnection(function(err, connection) {
        var  sql = 'insert into userinfo(UserName,UserPass) values(?,?)';
        var  sql_val = [userName2,userPwd2];

        connection.query( sql,sql_val, function(err, result) {
            if(err){
                res.render('register',{ title: '用户注册'});
            }else{
                res.render('newUser',{ title: '欢迎新用户',result:'true' });
                // res.redirect('/login');
            }
        });
        connection.release();
    });
});

module.exports = router;